﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Mvc;

namespace AutoPartsSearch.Web.HtmlHelpers
{
    public static class LanguageHelper
    {
        public static MvcHtmlString LanguageButton(this HtmlHelper helper, 
            string langName, 
            string languageActionLink, 
            string @class = "ui-state-default ui-corner-bottom", 
            string selectedClass = "ui-state-active")
        {
            StringBuilder sb = new StringBuilder();
            TagBuilder tagBuilder = new TagBuilder("div");
            tagBuilder.MergeAttribute("class",
                                      Thread.CurrentThread.CurrentUICulture.Name.Equals(langName, StringComparison.CurrentCultureIgnoreCase)
                                          ? @class + " " + selectedClass
                                          : @class);
            tagBuilder.InnerHtml = languageActionLink;
            sb.Append(tagBuilder.ToString());
            return MvcHtmlString.Create(sb.ToString());
        }
    }
}